load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "sortexec",
    srcs = [
        "multi_way_merge.go",
        "parallel_sort_spill_helper.go",
        "parallel_sort_worker.go",
        "sort.go",
        "sort_partition.go",
        "sort_spill.go",
        "sort_util.go",
        "topn.go",
        "topn_chunk_heap.go",
        "topn_spill.go",
        "topn_worker.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/executor/sortexec",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/executor/internal/exec",
        "//pkg/expression",
        "//pkg/planner/core/operator/physicalop",
        "//pkg/planner/util",
        "//pkg/sessionctx/vardef",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/channel",
        "//pkg/util/chunk",
        "//pkg/util/dbterror/exeerrors",
        "//pkg/util/disk",
        "//pkg/util/logutil",
        "//pkg/util/memory",
        "//pkg/util/sqlkiller",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "sortexec_test",
    timeout = "short",
    srcs = [
        "benchmark_test.go",
        "parallel_sort_spill_test.go",
        "parallel_sort_test.go",
        "sort_spill_test.go",
        "sort_test.go",
        "sortexec_pkg_test.go",
        "topn_spill_test.go",
    ],
    embed = [":sortexec"],
    flaky = True,
    shard_count = 19,
    deps = [
        "//pkg/config",
        "//pkg/executor/internal/exec",
        "//pkg/executor/internal/testutil",
        "//pkg/executor/internal/util",
        "//pkg/expression",
        "//pkg/expression/exprstatic",
        "//pkg/parser/mysql",
        "//pkg/planner/core/operator/physicalop",
        "//pkg/planner/util",
        "//pkg/session/sessmgr",
        "//pkg/sessionctx/vardef",
        "//pkg/testkit",
        "//pkg/testkit/testfailpoint",
        "//pkg/types",
        "//pkg/util/chunk",
        "//pkg/util/dbterror/exeerrors",
        "//pkg/util/memory",
        "//pkg/util/mock",
        "//pkg/util/sqlkiller",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
    ],
)
